package com.example.demo.wuyi;

import com.example.demo.OkHttpUtil;

import java.io.FileOutputStream;
import java.util.HashMap;

/**
 * @Author: hwq
 * @Date: 2021/9/4 9:05
 * @Version 1.0
 */
public class Biquge1 {


    public static void main(String[] args) {
        ///网址
        String o = "http://www.gegedown.com/0/51472/39156429.html";
        //文件路径
        String filename = "D:/重回1989.txt";
        try (FileOutputStream fos = new FileOutputStream(filename, true)) {
            for (int j = 1; j < 512; j++) {
                if(o==null){
                    System.out.println("写入完成!");
                    return;
                }
                Thread.sleep(5000);
                o = OkHttpUtil.get2(o, new HashMap<>(), fos,j);
                while (o.equals("fail")){
                    System.out.println("fail");
                    Thread.sleep(30000);
                    o = OkHttpUtil.get1(o, new HashMap<>(), fos,j);
                }
                System.out.println("写入" + j + "章");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }

}
